<?php
if (!defined('BASEPATH'))
	exit ('No direct script access allowed');

class Welcome extends CI_Controller {
	function __construct() {
		parent :: __construct();
	}
	function index() {
		$this->load->view('login');
	}
	function check() {
		$username = isset ($_POST['username']) ? $_POST['username'] : '';
		$passwords = isset ($_POST['passwords']) ? $_POST['passwords'] : '';
		$this->load->model('User_m');
		$user = $this->User_m->check_login($username, $passwords);
		if (count($user) <= 0) {
			$this->data['err'] = '错误：用户名或者密码错误！';
			$this->load->view('login', $this->data);
		} else {
			$this->session->set_userdata(array (
				'userid' => $user->id,
				'username' => $user->username
			));
			Header("Location:" . site_url('admin/home'));
		}
	}
}